<template>
	<view class="contain">
		<web-view :webview-styles="webviewStyles" :src="url" @message="postMessage"></web-view>
	</view>
</template>

<script>
	import { setTitleColor } from '@/utils/index.js'
	
	export default {
		data() {
			return {
				webviewStyles: {
                    progress: {
                        color: '#FF3333'
                    }
                },
				url: '',
				url_detail: ''
			}
		},
		methods: {
			postMessage(evt){
				console.log('接收到的消息：' + JSON.stringify(evt));
			},
			updateQueryStringParameter(uri, key, value) {
				if(value){
					if(uri.indexOf("?") != -1){
						uri = uri+"&"+key+"="+value
					}else{
						uri = uri+"?"+key+"="+value
					}
				}
				return uri;
			}
		},
		onShow(){
		},
		onLoad(opt){
			this.url = unescape(opt.url);
			// this.url_detail = opt.url_detail;
			this.url = this.updateQueryStringParameter(this.url, "auth_token", uni.getStorageSync("auth_token"))
			this.url = this.updateQueryStringParameter(this.url, "tpjk_app_version", uni.getStorageSync("tpjk_app_version"))
			setTitleColor();
		},
		onNavigationBarButtonTap:function(e){
			uni.navigateTo({
				url: '/pages/home_webview/home_webview?url=http://www.91fld.com/wallet/withdrawMethod/bankcard/add/2'
			});
		},
	}
</script>

<style>
.contain{overflow: auto; background: #FFFFFF;}
</style>
